package main

import (
	"math/rand/v2"

	"fiberx/middleware"
	"fiberx/router"

	"github.com/gofiber/fiber/v2"
)

func Init(h *fiber.App) {
	//middleware.InitSession(h)
	middleware.InitCSRF(h)
	middleware.InitCors(h)
	//render.InitHTML(h)
}

func main() {
	h := fiber.New()
	Init(h)
	h.Use("/user", func(c *fiber.Ctx) error {
		n := rand.IntN(1)
		if n == 0 {
			return c.Next()
		}
		return c.SendString(c.Path())
	})
	for _, iRouter := range router.InitRouterx() {
		iRouter.InitRoute(h)
	}
	h.Listen("0.0.0.0:8080")
	//h.ListenTLS()
}
